package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.SysUserMapper;
import com.eos.orm.mybatis.model.SysUser;
import com.eos.orm.mybatis.model.SysUserExample;
/**
 * sys_user系统用户表的CURD操作
 * @author sz
 *
 */
public class SysUserMapperImpl extends AbstractSqlSessionFactory implements
		SysUserMapper {

	public int countByExample(SysUserExample example) {
		return 0;
	}

	public int deleteByExample(SysUserExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysUserMapper mapper = session.getMapper(SysUserMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysUserMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(SysUser record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysUserMapper mapper = session.getMapper(SysUserMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysUserMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(SysUser record) {
		return 0;
	}

	public List<SysUser> selectByExample(SysUserExample example) {
		List<SysUser> templist = new ArrayList<SysUser>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysUserMapper mapper = session.getMapper(SysUserMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysUserMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public SysUser selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysUserMapper mapper = session.getMapper(SysUserMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysUserMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(SysUser record, SysUserExample example) {
		return 0;
	}

	public int updateByExampleSelective(SysUser record, SysUserExample example) {
		return 0;
	}

	public int updateByPrimaryKey(SysUser record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(SysUser record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysUserMapper mapper = session.getMapper(SysUserMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysUserMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
